﻿@model IEnumerable<TruckingApplication.Dal.EntityModels.ORDER>

@*<p>
    @Html.ActionLink("Create New", "Create")
</p>*@

@(Html.Kendo().Grid(Model)
    .Name("Grid")
    .Columns(columns =>
        {
            columns.Bound(o => o.orderNum);
            columns.Bound(o => o.gross);
            columns.Bound(o => o.paidStatus);
            columns.Bound(o => o.dueDate);
            columns.Bound(o => o.pickupCity);
            columns.Bound(o => o.pickupState);
            columns.Bound(o => o.dropOffCity);
            columns.Bound(o => o.dropOffState);
            columns.Bound(o => o.ORDER_STATUS.status);
        })
    .Groupable()
    .Pageable()
    .Sortable()
    .Scrollable()
    .Filterable()
    .DataSource(datasource => datasource.Ajax().Read(read => read.Action("Orders_Read", "Grid"))
        )
    )
<table id="tableMgmt" class="display" style="max-width:99%;">
    <thead>
        <tr>
            <th></th>
            <th>
                Order #
            </th>
            <th>
                Gross
            </th>
            <th>
                Paid
            </th>
            <th>
                Due Date
            </th>
            <th>
                Pickup City
            </th>
            <th>
                Pickup State
            </th>
            <th>
                Drop-Off City
            </th>
            <th>
                Drop-Off State
            </th>
            <th>
                Status
            </th>
        </tr>
    </thead>
    <tbody>
@foreach (var item in Model)
{
    <tr>
        <td>
            @Html.ActionLink("Edit", "Edit", "Order", new { id = item.orderID }, null) | 
            @Html.ActionLink("Details", "Details", "Order", new { id = item.orderID }, null)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.orderNum)
        </td>
        <td>
            @{var gross = string.Format("{0:C}", item.gross);}
            @gross
        </td>
        <td>
            @Html.DisplayTextFor(modelItem => item.paidStatus)
        </td>
        <td>
            @{var date = item.dueDate.ToString("MM.dd.yy");}
            @date
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.pickupCity)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.pickupState)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.dropOffCity)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.dropOffState)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.ORDER_STATUS.status)
        </td>
    </tr>
}
    </tbody>
    <tfoot>
        <tr>
            <th></th>
            <th>
                Order #
            </th>
            <th>
                Gross
            </th>
            <th>
                Paid
            </th>
            <th>
                Due Date
            </th>
            <th>
                Pickup City
            </th>
            <th>
                Pickup State
            </th>
            <th>
                Drop-Off City
            </th>
            <th>
                Drop-Off State
            </th>
            <th>
                Status
            </th>
        </tr>
    </tfoot>
</table>
